package com.hpin.mlxteacher.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.hpin.mlxteacher.R;
import com.hpin.mlxteacher.adapter.BabyTreeAdapter;
import com.hpin.mlxteacher.base.BaseFragment;
import com.hpin.mlxteacher.pulltorefush.PullToRefreshListView;
import com.hpin.mlxteacher.tree.ReleaseActivity;

import java.util.ArrayList;
import java.util.List;

/**
 * 宝宝树fragment
 * Created by Administrator on 2015/7/15.
 */
public class BabyTreeFragment extends BaseFragment {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        View babyTreeView = inflater.inflate(R.layout.fragment_baby_tree, null);

        initWidget(babyTreeView);

        return babyTreeView;
    }

    private void initWidget(View babyTreeView) {

//        TextView tv_left = (TextView) babyTreeView.findViewById(R.id.tv_left);
        TextView tv_title = (TextView) babyTreeView.findViewById(R.id.tv_title);
        TextView tv_right = (TextView) babyTreeView.findViewById(R.id.tv_right);
        tv_right.setVisibility(View.VISIBLE);

//        tv_left.setText(getResources().getString(R.string.rl_baby_tree));
        tv_title.setText(getResources().getString(R.string.rl_baby_tree));
        tv_right.setText(getResources().getString(R.string.baby_tree_release));

        PullToRefreshListView plv_friend = (PullToRefreshListView) babyTreeView.findViewById(R.id.plv_friend);

        List<String> sizes = new ArrayList<String>();
        for(int i =0; i<9 ; i++) {
            sizes.add(i+"");
        }

        BabyTreeAdapter babyTreeAdapter = new BabyTreeAdapter(getActivity(), sizes);
        plv_friend.setAdapter(babyTreeAdapter);

        tv_right.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                Intent intent = new Intent(getActivity(), ReleaseActivity.class);
                startActivity(intent);
            }
        });

    }

}


